/*!
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
if (YAHOO === undefined) {var YAHOO = {};}
YAHOO.lang = {
    /**
     * Utility to set up the prototype, constructor and superclass properties to
     * support an inheritance strategy that can chain constructors and methods.
     * Static members will not be inherited.
     *
     * @method extend
     * @static
     * @param {Function} subc   the object to modify
     * @param {Function} superc the object to inherit
     * @param {Object} overrides  additional properties/methods to add to the
     *                              subclass prototype.  These will override the
     *                              matching items obtained from the superclass
     *                              if present.
     */
    extend: function(subc, superc, overrides) {
	if (! superc || ! subc) {
            throw new Error("YAHOO.lang.extend failed, please check that " +
                            "all dependencies are included.");
	}
	
	var F = function() {};
	F.prototype = superc.prototype;
	subc.prototype = new F();
	subc.prototype.constructor = subc;
	subc.superclass = superc.prototype;
     
	if (superc.prototype.constructor == Object.prototype.constructor) {
            superc.prototype.constructor = superc;
	}
 
	if (overrides) {
	    var i;
            for (i in overrides) {
		subc.prototype[i] = overrides[i];
            }
 
	    /*
	     * IE will not enumerate native functions in a derived object even if the
	     * function was overridden.  This is a workaround for specific functions 
	     * we care about on the Object prototype. 
	     * @property _IEEnumFix
	     * @param {Function} r  the object to receive the augmentation
	     * @param {Function} s  the object that supplies the properties to augment
	     * @static
	     * @private
	     */
	    var _IEEnumFix = function() {},
		ADD = ["toString", "valueOf"];
	    try {
		if (/MSIE/.test(navigator.userAgent)) {
		    _IEEnumFix = function(r, s) {
			for (i = 0; i < ADD.length; i = i + 1) {
			    var fname = ADD[i], f = s[fname];
			    if (typeof f === 'function' && f != Object.prototype[fname]) {
				r[fname] = f;
			    }
			}
		    };
		}
	    } catch (ex) {};
            _IEEnumFix(subc.prototype, overrides);
	}
    }
};
